package com.grieous.wow.dao.impl;

import java.util.List;
import java.util.Map;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import com.grieous.wow.dao.ArticleDao;
import com.grieous.wow.entity.Article;
import com.grieous.wow.entity.ArticleCategory;

@Repository("articleDao")
public class ArticleDaoImpl extends SqlSessionDaoSupport implements ArticleDao{


	@Override
	public int add(Article t) {
		return getSqlSession().insert("mybatis.mapper.ArticleMapper.insertArticle", t);
		

	}

	@Override
	public int delete(Map<String, Object> map) {
		return getSqlSession().delete("mybatis.mapper.ArticleMapper.deleteArticle",
				map);

	}

	@Override
	public int delete(Article t) {
		return 0;

	}

	@Override
	public int update(Article t) {
		return getSqlSession().update("mybatis.mapper.ArticleMapper.updateArticle", t);

	}

	@Override
	public int update(Map<String, Object> map) {
		return getSqlSession().update("mybatis.mapper.ArticleMapper.updateArticle",
				map);

	}

	@Override
	public List<Article> findListByCondition(Map<String, Object> map) {
		return getSqlSession().selectList(
				"mybatis.mapper.ArticleMapper.getArticle", map);
	}

	@Override
	public int findCountByCondition(Map<String, Object> map) {
		Object obj = getSqlSession().selectOne(
				"mybatis.mapper.ArticleMapper.getArticleCount", map);
		return (Integer) (obj == null ? 0 : obj);
	}

	@Override
	public List<ArticleCategory> getArticleByCatrgory(Map<String, Object> map) {
		return getSqlSession().selectList(
				"mybatis.mapper.ArticleMapper.getArticleByCategory", map);
	}
}
